/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.seg.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Programador
 */
@Entity
@Table(name = "SEG_PROVINCIA")
@NamedQueries({@NamedQuery(name = "Provincia.findAll", query = "SELECT p FROM Provincia p"), @NamedQuery(name = "Provincia.findByIdProvincia", query = "SELECT p FROM Provincia p WHERE p.idProvincia = :idProvincia"), @NamedQuery(name = "Provincia.findByNomProvincia", query = "SELECT p FROM Provincia p WHERE p.nomProvincia = :nomProvincia")})
public class Provincia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_PROVINCIA", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long idProvincia;
    @Column(name = "NOM_PROVINCIA", length = 50)
    private String nomProvincia;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fidSegProvincia", fetch = FetchType.LAZY)
    private List<Distrito> distritoCollection;
    @JoinColumn(name = "FID_SEG_DEPARTAMENTO", referencedColumnName = "ID_DEPARTAMENTO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Departamento fidSegDepartamento;

    public Provincia() {
    }

    public Provincia(Long idProvincia) {
        this.idProvincia = idProvincia;
    }

    public Long getIdProvincia() {
        return idProvincia;
    }

    public void setIdProvincia(Long idProvincia) {
        this.idProvincia = idProvincia;
    }

    public String getNomProvincia() {
        return nomProvincia;
    }

    public void setNomProvincia(String nomProvincia) {
        this.nomProvincia = nomProvincia;
    }

    public List<Distrito> getDistritoCollection() {
        return distritoCollection;
    }

    public void setDistritoCollection(List<Distrito> distritoCollection) {
        this.distritoCollection = distritoCollection;
    }

    public Departamento getFidSegDepartamento() {
        return fidSegDepartamento;
    }

    public void setFidSegDepartamento(Departamento fidSegDepartamento) {
        this.fidSegDepartamento = fidSegDepartamento;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProvincia != null ? idProvincia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Provincia)) {
            return false;
        }
        Provincia other = (Provincia) object;
        if ((this.idProvincia == null && other.idProvincia != null) || (this.idProvincia != null && !this.idProvincia.equals(other.idProvincia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.seg.be.Provincia[idProvincia=" + idProvincia + "]";
    }

}
